cmake_minimum_required(VERSION 3.20)
project(path_test)

message("cmake current dir: ${CMAKE_CURRENT_SOURCE_DIR}")

set(path "/usr/local/bin/myfile")
cmake_path(RELATIVE_PATH path BASE_DIRECTORY "/usr/local" OUTPUT_VARIABLE output)
message("the relative path ${path} for base /usr/local is ${output}")

cmake_path(RELATIVE_PATH path OUTPUT_VARIABLE output)
message("the relative path ${path} for base ${CMAKE_CURRENT_SOURCE_DIR} is ${output}")

set(path "/usr/local/bin/myfile")
cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/usr/local" OUTPUT_VARIABLE output)
message("the absolute path ${path} for base /usr/local is ${output}")
cmake_path(ABSOLUTE_PATH path OUTPUT_VARIABLE output)
message("the absolute path ${path} for base ${CMAKE_CURRENT_SOURCE_DIR} is ${output}")

set(path "mydir/myfile")
cmake_path(ABSOLUTE_PATH path BASE_DIRECTORY "/usr/local" OUTPUT_VARIABLE output)
message("the absolute path ${path} for base /usr/local is ${output}")
cmake_path(ABSOLUTE_PATH path OUTPUT_VARIABLE output)
message("the absolute path ${path} for base ${CMAKE_CURRENT_SOURCE_DIR} is ${output}")

set(path "/usr/local/bin/myfile")
cmake_path(NATIVE_PATH path output)
message("the native path of ${path} is: ${output}")


set(path "/usr/local/bin/myfile" "/tmp/mydir")
cmake_path(CONVERT "${path}" TO_CMAKE_PATH_LIST output)
message("1: the native path ${path} to cmake-style: ${output}")
set(path "/usr/local/bin/myfile:/tmp/mydir")
cmake_path(CONVERT "${path}" TO_CMAKE_PATH_LIST output)
message("2: the native path ${path} to cmake-style: ${output}")

set(path "/usr/local/bin/myfile" "/tmp/mydir")
cmake_path(CONVERT "${path}" TO_NATIVE_PATH_LIST output)
message("the cmake-style path ${path} to native path: ${output}")


set(path "/usr/local/bin/myfile")
cmake_path(HASH path hash_path)
cmake_path(APPEND path2 "/usr/local" "bin/myfile")
cmake_path(HASH path2 hash_path2)
message("path1:${path}, path1 hash:${hash_path}")
message("path2:${path2}, path2 hash:${hash_path2}")
